Depth Of Field Info - Chdk version
Written for all CHDK cameras Latest version: https://gist.github.com/pigeonhill/600ce3c066c5f8f22b722a2a311b2c21 Tested on: G1X, G5X and G7X Note: This script has been superseded by the DOFIZ script above, which has the same functionality as this script, from a focus point of view, but has the addition of exposure bracketing control. This script will thus note be updated as of Jan 2020. But you are encouraged to read the focusing functionality to support your DOFIZ use. This script is simple but incredibly powerful, if you appreciate what’s going on. The script is written to run in the ‘background’, ie while you are working in non-Alt mode, but, of course, will be bumped if you start another CHDK script. It works in all modes, eg M, Av, Tv or P; but works best in Manual Focus mode, where you have control of the focus. I wrote it to complement the depth of field information currently supplied by CHDK, eg depth of field based on defocus blur alone and ‘normal’ focus quality circle of confusion assumptions. Note the current version of DOFIC uses the CHDK CoC as the focus stacking overlap criterion. DOFIC was written to take up a low profile, compact, footprint on the screen. The current version of DOFIC does the following: *It tells you the defocus blur at infinity, in microns *It tells you the diffraction blur through the field, in microns *It tells you the total blur at infinity in microns *It tells you if you are in front or behind the hyperfocal *It tells you how many images you need to take to cover from your current focus position to the hyperfocal *It tells you if you have a positive of negative overlap, relative to the last image captured *It tells you if you are at the same position as the last image taken The general format for DOFIC is as follows: n, < or >, H: inf_blur / diff_blur / total_blur or – or + DOFIC uses the CHDK console, so positioning on the screen is restricted to the CHDK-limited console area, however, some repositioning may be accomplished by tweaking the script (at the end). You may run DOFIC from Alt mode, as usual, or enable it as an Auto run script at camera start up. At start up, with no image yet captured, DOFIC would look something like this: >H: 9/4/10 X This tells us that an image has yet to be taken, ie X; that we are focused beyond the hyperfocal, ie >H, and the defocus, diffraction and total blurs, in microns, are 9, 4 and 10. As an aside: If you can’t yet think in terms of microns, for focusing, remember that, at the hyperfocal (H), the defocus blur at infinity, in microns is simply the CoC; and at H/2 the defocus blur is also the CoC. In general, the blur at the near and far depth of fields is, of course, the CoC. Note that CHDK, like many depth of field calculators, doesn’t use a very ‘high quality’ criterion for the CoC, eg typically around 30 microns divided by the crop factor of your camera is the ‘industry standard’. This is more than OK for on-screen presentation and printing ‘OK’ quality prints. But not the best you can do, ie for printing and competition judging, say. A sensible lower limit is twice your sensor’s pixel pitch, eg on my G1X the pitch is 4.27 microns; so a defocus blur at infinity of less than, say, 8-9 microns is not going to add much. Thus, 8-9 microns, it where I would call a stop to infinity focusing, ie go beyond the hyperfocal but not by too much. Why is infinity focusing important? Because as soon as you focus at Canon reported infinity, there is no data. In other words, you could be ‘beyond’ where the camera thinks infinity is or in front of it. Yes, you and your camera can operate in Buzz Lightyear mode ;-) DOFIC dynamically changes as you refocus; but once you have captured an image, DOFIC really shows it potential. As an example assume we have focused on a near object and DOFIC reports the following: 3 DOFIC is telling us that you are focused less than the hyperfocal, that you need to take three focus brackets to cover yourself to the hyperfocal. See my auto focus bracketing script for more information on non-macro, focus bracketing for landscapes: https://chdk.fandom.com/wiki/Landscape_Focus_Bracketing_:_perfect_near_to_far_focus_brackets) However, what we want is the currently focused point to be in focus, as well as the far field, ie at infinity. This is a typical landscape photography use case. With DOFIC we now know that: one image won’t do; that we will need to take about 3 images to just cover ourselves to the hyperfocal; and that if we want a higher quality than the CoC at infinity, we will need to take an additional image at greater than H. So let’s do that and take the first image. In this example, DOFIC now changes to look like this: 3 The change being that DOFIC is telling us that the current focus position is the same as the last captured image. Until another image is taken, this will remain the case; thus, you can always return to the focus position, eg and repeat the capture. We now need to move the focus towards infinity, but where and when to stop is the question; and, of course, DOFIC will provide the answer. If you move a bit towards infinity DOFIC will look something like this: 2 This tells us that we have two images to go to the hyperfocal and that we still have a positive overlap. DOFIC is also telling us that the defocus blur has reduced to 58 microns, as we are getting closer to infinity, that, obviously the diffraction blur is still 4 microns, as this is only dependent on the aperture, and that the total blur is around 58 microns, ie Sqrt(58*58+4*4) = 58.13. Plus, we now only have two images to reach the hyperfocal. If we go further we would, in this example, see something like this: 2 The key piece of information being the - feedback, telling us we have a focus gap. Thus all we need to do is adjust the focus until we just see a + again. It is now a simple matter of repeating the above until we see, say, the following: >H: 16/4/16 + This tells us that we are now infinity focusing beyond the hyperfocal and that our infinity blurs indicate we are still close to the hyperfocal, eg 30/crop: where we could stop if required. However, assuming you are using DOFIC to get greater focus quality out of your camera, you now need to take a final infinity focus shot. For example, when DOFIC tells you the following: >H: 7/4/8 + That is, we are now at the infinity focused point, ie >H, where our total blur at infinity is 8 microns. That is about the best we can do and guarantee seeing focus information, rather than the dreaded, no data, Infinity symbol. If you are still confused about using blurs to aid focusing, DOFIC has a menu option to show the infinity blur size, in microns, when you are focused at H and when the infinity blur is the same as two sensor pixels. In other words, the optimum infinity focus position. If this feature is switched on you will see something like this example from my G1X: 16:8 2 DOFIC will also try and minimize redundant information. For instance, if the defocus blur and the total blur are the same, then DOFIC only shows the total, thus alerting you to the fact that either the diffraction or defocus blur is dominating. Once you have captured your focus brackets, the next step is to post process them in the software of your choice. You can use Photoshop auto focus stacking, Photoshop masks, or other proprietary focus stacking software. DOFIC can, of course, be used in other ways, for example, if you have the standard CHDK depth of field info on, you can combine the CHDK supplied info with DOFIC’s to help you make focus decisions. I’ve tried to make the DOFIC script as transparent as possible, so you should be able to tweak it, eg position the DOFIC display to better fit your screen’s layout. As DOFIC is running in the background, if you need to use the CHDK menus, simply enable Alt mode and interrupt the script by taking a shot. Once you exit the CHDK menu, re-enable DOFIC from Alt mode by taking a shot. If DOFIC 'disappears' when running, or you can't see it initially, simply change focus. As I say, DOFIC was designed to run in Manual Focus mode, but it will run in other focus modes. In the script's menu you can specify the display timeout. If you see DOFIC 'disappear' from the screen, simply do a long half-shutter press or move focus. Finally, I welcome any feedback on DOFIC, ie stability or problems, and, of course, any suggestions to make it better.